<?php

/**
 * 后台操作日志模型
 * @author yupoxiong<i@yupoxiong.com>
 */

declare(strict_types=1);

namespace app\admin\model;

use app\common\model\Page;
use think\facade\Db;
use think\model\relation\HasOne;
use think\model\concern\SoftDelete;
use think\model\relation\BelongsTo;

/**
 * Class AdminLog
 * @package app\admin\model
 * @property string $log_ip
 */
class PageClickLog extends AdminBaseModel
{
    use SoftDelete;
    /**
     * @var array 搜索的字段：操作，URL
     */
    public array $searchField = [
        'page_keys',
        'url',
    ];

    public array $whereField = [
        'admin_user_id'
    ];

    public function getClick($keys,$param)
    {
        $where_string = 'create_time>="' . strtotime($param['start_time']) . '" and create_time<="' . strtotime($param['end_time']).'"' ;
        $data = Db::query('select page_log_id,count(*) as c from page_click_log where page_keys="' . $keys . '" and '.$where_string.' group by page_log_id');
        if (count($data) > 0) {
            return $data;
        } else {
            return -1;
        }
    }
}
